<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <br>
    <!-- 面包屑 -->
    <!-- 卡片 -->
    <el-card>
      <el-row>
        <el-col :span="8">
          <el-input
            placeholder="请输入内容"
            v-model="OrdersQuery.query"
            class="input-with-select"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              @click="xr(OrdersQuery.query)"
            ></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="OrdersList.goods">
        <el-table-column
          type="index"
          label="#"
        ></el-table-column>
        <el-table-column
          prop="order_number"
          label="订单编号"
        ></el-table-column>
        <el-table-column
          prop="order_price"
          label="订单价格"
        ></el-table-column>
        <el-table-column
          prop="order_pay"
          label="是否付款"
        >
          <template slot-scope="scope">
            <div>
              <el-tag
                type="success"
                v-show="scope.row.order_pay==0"
              >未付款</el-tag>
              <el-tag
                type="danger"
                v-show="scope.row.order_pay==1"
              >已付款</el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="is_send"
          label="是否发货"
        ></el-table-column>
        <el-table-column label="下单时间">
          <template slot-scope="scope">
            <div>
              {{scope.row.create_time|time}}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template>
            <div>
              <el-button
                type="primary"
                icon="el-icon-edit"
                @click="dialogVisible=true"
              ></el-button>
              <el-button
                type="warning"
                icon="el-icon-location-outline"
                @click="dialogVisible1=true"
              ></el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!-- 表格 -->
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="OrdersQuery.pagenum"
        :page-sizes="[2, 5, 8, 10]"
        :page-size="OrdersQuery.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
      <!-- 分页 -->
    </el-card>
    <!-- 卡片 -->
    <!-- 编辑模态框 -->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
    >
      省市区/县:
      <!-- 练级菜单 -->
      <el-cascader
        :options="city"
        :props="{ expandTrigger: 'hover',label:'label',value:'value' }"
      ></el-cascader>
      <!-- 练级菜单 -->
      <span
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button
          type="primary"
          @click="dialogVisible = false"
        >确 定</el-button>
      </span>
    </el-dialog>
    <!-- 编辑模态框 -->
    <!-- 物流进度 -->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible1"
      width="30%"
    >
      <!-- 时间线 -->
      <el-timeline>
        <el-timeline-item
          v-for="(activity, index) in datas"
          :key="index"
          :icon="activity.icon"
          :type="activity.type"
          :color="activity.color"
          :size="activity.size"
          :timestamp="activity.timestamp"
        >
          {{activity.context}}
        </el-timeline-item>
      </el-timeline>
      <!-- 时间线 -->
      <span
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button
          type="primary"
          @click="dialogVisible = false"
        >确 定</el-button>
      </span>
    </el-dialog>
    <!-- 物流进度 -->
  </div>
</template>

<script>
import city from "@/assets/city.js";
console.log("数据", city);
export default {
  data() {
    return {
      city,
      OrdersQuery: {
        query: "",
        pagenum: 1,
        pagesize: 2
      },
      OrdersList: [],
      total: 0,
      dialogVisible: false,
      dialogVisible1: false,
      datas: [
        {
          time: "2018-05-10 09:39:00",
          ftime: "2018-05-10 09:39:00",
          context: "已签收,感谢使用顺丰,期待再次为您服务",
          location: "",
          type: "primary",
          icon: "el-icon-check"
        },
        {
          time: "2018-05-10 08:23:00",
          ftime: "2018-05-10 08:23:00",
          context:
            "[北京市]北京海淀育新小区营业点派件员 顺丰速运 95338正在为您派件",
          location: ""
        },
        {
          time: "2018-05-10 07:32:00",
          ftime: "2018-05-10 07:32:00",
          context: "快件到达 [北京海淀育新小区营业点]",
          location: ""
        },
        {
          time: "2018-05-10 02:03:00",
          ftime: "2018-05-10 02:03:00",
          context:
            "快件在[北京顺义集散中心]已装车,准备发往 [北京海淀育新小区营业点]",
          location: ""
        },
        {
          time: "2018-05-09 23:05:00",
          ftime: "2018-05-09 23:05:00",
          context: "快件到达 [北京顺义集散中心]",
          location: ""
        },
        {
          time: "2018-05-09 21:21:00",
          ftime: "2018-05-09 21:21:00",
          context: "快件在[北京宝胜营业点]已装车,准备发往 [北京顺义集散中心]",
          location: ""
        },
        {
          time: "2018-05-09 13:07:00",
          ftime: "2018-05-09 13:07:00",
          context: "顺丰速运 已收取快件",
          location: ""
        },
        {
          time: "2018-05-09 12:25:03",
          ftime: "2018-05-09 12:25:03",
          context: "卖家发货",
          location: "",
          type: "primary",
          icon: "el-icon-check"
        },
        {
          time: "2018-05-09 12:22:24",
          ftime: "2018-05-09 12:22:24",
          context: "您的订单将由HLA（北京海淀区清河中街店）门店安排发货。",
          location: ""
        },
        {
          time: "2018-05-08 21:36:04",
          ftime: "2018-05-08 21:36:04",
          context: "商品已经下单",
          location: ""
        }
      ]
    };
  },
  created() {
    this.xr();
    this.datas.forEach((item, index) => {
      if (index !== 0) {
        item.type = "success";
        item.icon = "el-icon-check";
      }
    });
  },
  methods: {
    //   渲染订单列表
    async xr() {
      let res = await this.$API.Orders(this.OrdersQuery);
      console.log(res);
      this.OrdersList = res;
      this.total = res.total;
    },
    handleSizeChange(v) {
      this.OrdersQuery.pagesize = v;
      this.xr();
    },
    handleCurrentChange(v) {
      this.OrdersQuery.pagenum = v;
      this.xr();
    }
  }
};
</script>

<style scoped >
</style>
